﻿using System;
using System.Collections.Generic;
using System.IO;

using System.Text;

namespace Flame.Dlr
{
    public class ScriptBrute
    {
        public string Code { get; set; }
        public string Header { get; set; }
    }


    public class Script
    {
        public Type Language { get; set; }
        public string Code { get; set; }


        protected virtual void fromParameters(string[] parameters)
        {
        }


        public Script(ScriptBrute s)
        {
            string[] parameters = s.Header.Split(';');
            Language = Languages.Get(parameters[0]);
            if (Language == null) throw new ExceptionExec(parameters[0]);
            fromParameters(parameters);
            Code = s.Code;
        }

        public Script(Type language, string code)
        {
            Language =  language;
            Code = code;
        }

        public virtual ScriptBrute Brute
        {
            get
            {
                return new ScriptBrute() { Code = Code, Header = Language.Name };
            }
            set
            {

            }
        }
    }
    /*public class Cell //: ICell
    {
        public string Code { get; set; }
        public Type Language { get; set; }

        public Cell() { Language = Languages.Get("None"); Code = ""; }
        public Cell(CellHeader s)
        {
            string[] parameters = s.Header.Split(';');
            Language = Languages.Get(parameters[0]);
            if(Language == null) throw FlameException

           /* // temp
            string lang = Language.ToLower();
            if (lang == "python" || lang == "py")
                Language = "IronPython";
            else if (lang == "ruby" || lang == "rb")
                Language = "IronRuby";
            * /

            Code = s.Code;
        }

       /* public Cell(string pathfile)
        {
            FileInfo fi = new FileInfo(pathfile);
            Code = File.ReadAllText(fi.FullName);
            switch (fi.Extension)
            {
                case ".py":
                    Language = Languages.IronPython;
                    break;
                default:
                    Language = Languages.None;
                    break;
            }
        }* /

        public virtual CellHeader Base
        {
            get
            {
                return new CellHeader(){ Code = Code, Header = Language.ToString() };
            }
        }

        
    }*/
}
